Graphs are mathematical structures that can model and indicate relationships between different objects or entities. For example, a graph can include different nodes that are connected to each other by edges. Each node can represent an object or entity, while each edge can represent the relationship between the objects and/or entities it connects. An edge can be undirected (e.g., there is no directional relationship represented by the edge), or an edge can be directional (e.g., there is a direction associated with the connection between two nodes) and therefore have a source node and a destination node.
Graphs can be stored in a graph database. A property graph database can be optimized for storage and retrieval of schema-less connected data. A data point can be represented as a node within a graph. A node can be associated with multiple labels in addition to an optional attribute-set describing the node. For example, a node of type “Person” can have attributes {“Surname”, “Given name”, and “Age”}.
Edges can be associated with a “relationship-type” specifying its type. For example, an edge can have a relationship-type “Visit” that indicates that a person identified by a source node visited a country identified by a destination node. In addition, an edge can have an attribute-set. For example, an edge with relationship-type “Visit” can have attributes {“Purpose”, “Length”}.
Edges can be stored in a graph database as a matrix. For example, a directional edge can connect a node i to a node j. In such case, node i is the source node while node j is the destination node. This connection can be noted by setting the graph matrix at position [i,j] to 1. Matrix rows can be used to represent source nodes while matrix columns represent destination nodes, or vice versa.
Below is an example of a matrix representing a graph with three nodes (node 0, node 1, and node 2):
  G  =      [                            ·                          ·                          1                                      ·                          ·                          1                                      ·                          1                          ·                      ]  In this example, node 0 is connected to node 2, node 1 is connected to node 2, and node 2 is connected to node 1. This matrix can be referred to as an adjacency matrix. This is, it is a binary matrix, representing all connections within the graph regardless of the connection type.
Some graph matrices can be label matrices. A label matrix can be a diagonal binary matrix for a given label in which nodes having the given label are identified. For example, in a label matrix representing the label “L”, a node i labeled as “L” can be represented by a 1 at position [i, i]. Below is an example of a label matrix:
  L  =      [                            1                          ·                          ·                                      ·                          ·                          ·                                      ·                          ·                          1                      ]  As shown, this label matrix indicates that node 0 and node 2 have the label “L”.
Some graph matrices can be relation matrices. A relation matrix can be a binary matrix for a given relation-type in which edges having the given relation-type are identified. For example, in a relation matrix representing the relation-type “R”, an edge of relation-type “R” that connects node i to node j can be represented by a 1 at position [i,j]. Below is an example of a relation matrix:
  R  =      [                            ·                          1                          ·                                      ·                          ·                          ·                                      ·                          ·                          ·                      ]  As shown, this relation matrix indicates that node 0 is connected to node 1 via an edge of relation-type R.
Data regarding a graph can be retrieved from a graph database using a query language. For example, a query language such as OpenCypher can be used to retrieve data from a graph database. More particularly, a query can have the following format:                MATCH (a)-[:X]→(b)-[ ]→(c)←[:Z]-(d) RETURN cIn this format: “( )” represents a node; and “[ ]” represents an edge.        
Both nodes and edges may be assigned an alias and a label. A node can have the following format: (Alias: Label). An edge can have the following format: [Alias: Label]. A path can be formed by chaining nodes with edges. For example node A being connected to node B using an edge of type R can be represented as: (A)-[:R]→(B).
A connection can be specified using either a left-to-right arrow or a right-to-left arrow. The arrow can be omitted when the edge direction does not matter. The following are examples:                (A)-[:R]→(B)-A is connected to B.        (A)←[:R]-(B)-B is connected to A.        (A)-[:R]-(B)-A and B are connected.        
As a more particular example, if one wanted to find, for every person in a graph, which countries their friends visited, a query such as the following may be used:                MATCH (p:Person)-[:friend]→(f:Person)-[:visit]→(c:Country)        RETURN p, cHowever, such a query can be time-sensitive and resource-intensive. For example, such a query may require a linear traversal through many different edges of the graph, which can make returning a response to the query time-intensive.        
Accordingly, it is desirable to provide new methods, systems, and media for resolving graph database queries.